home *** CD-ROM | disk | FTP | other *** search
/ HyperLib 1997 Winter - Disc 1 / HYPERLIB-1997-Winter-CD1.ISO.7z / HYPERLIB-1997-Winter-CD1.ISO / オンラインウェア / PRG / nShell-Pro.sit / nShell-Pro / doc / nShell™ User's Guide.rsrc / TEXT_132.txt < prev    next >
Text File  |  1994-12-27  |  2KB  |  87 lines

  1.  
  2. Wildcards
  3.  
  4. Wildcards may be used to specify a set of files on the command line:
  5.  
  6.     % ls *.txt
  7.     jim.txt
  8.     bob.txt
  9.     %
  10.  
  11. In a shell environment wildcards are expanded on the command line, rather than within each command.  This means that expanded filenames are treated as text:
  12.  
  13.     % echo "These are my text files:" *.txt
  14.     These are my text files: jim.txt bob.txt
  15.     %
  16.  
  17. Wildcards may be matched within the current working directory or at the end of a pathname.  Matching in the middle of a pathname is not supported:
  18.  
  19. Good wildcard patterns:
  20.  
  21.     *.h
  22.     :tmp:*.h
  23.     "my disk:my folder:my *"
  24.  
  25. Bad wildcard patterns:
  26.  
  27.     *:tmp.h
  28.     "my disk:*:my file"
  29.  
  30. Wildcard Summary
  31.  
  32. *    - Match zero or more characters.  For example, b* matches the files "b", "bat", "belfry", and so on.
  33.  
  34. ?  -  Match exactly one character.  For example b? matches "bb", "bz, and so on.
  35.  
  36. [abc]  -  Match any character listed in the brackets.  For example b[cd] matches "bc" or "bd".
  37.  
  38. [a-d]  -  Match any character in the range "a" to "d".  For example, b[w-z] matches "bw", "bx", "by" or "bz".
  39.  
  40. [^abc]  -  Match any character not listed in the brackets.  For example b[!a-z] matches "b0" and "b2", but not "ba" or "bi".
  41.  
  42. ¥*  -  Match a literal "*".
  43.  
  44. ¥?  -  Match a literal "?".
  45.  
  46. ¥[  -  Match a literal "[".
  47.  
  48. Sample Patterns
  49.  
  50. *.txt  -  Match all files which end with ".txt".
  51.  
  52. b*  -  Match all files which start with "b".
  53.  
  54. *tt*  -  Match all files which contain a "tt" anywhere.
  55.  
  56. [abc]*  -  Match all files which start with an "a" or "b" or "c".
  57.  
  58. [a-zA-Z0-9]*  -  Match all files which start with an alphanumeric character.
  59.  
  60. b*[0-9]  -  Match all files which start with a "b" and end with a number.
  61.  
  62. Wildcards and Quotes
  63.  
  64. Macintosh filenames often contain spaces.  To allow matching on such names, the nShell allows quoting of wildcard specifications:
  65.  
  66. "my *"     Match all files which start with "my" and a space.
  67.  
  68. Note that the entire string is treated as a pattern. The command:
  69.  
  70. % echo "These are my files: my *"
  71.  
  72. would attempt to match files which start with "These are my...".  To list my files, I would use the command:
  73.  
  74. % echo "These are my files:" "my *"
  75.  
  76. In this case, only the second parameter is expanded as a wildcard.
  77.  
  78. Single quotes suppress wildcard expansion, as shown below.
  79.  
  80. Suppressing Wildcard Expansion
  81.  
  82. Strings contained within single quotes are not expanded:
  83.  
  84.     % echo 'my favorite pattern is *.txt'
  85.     my favorite pattern is *.txt
  86.  
  87. Backslash characters may be used to force single characters to be treated literally.